package com.a3dweijing.wetouch2.Common.RefreshRecycler;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.a3dweijing.wetouch2.Common.CallBack;
import com.a3dweijing.wetouch2.R;

import java.util.List;

/**
 * Created by Administrator on 2018/3/19.
 */

public abstract class CommonrRecyclerAdapter<T> extends RecyclerView.Adapter
{
    protected Context mContext;
    
    protected List<T> mDatas;
    
    protected LayoutInflater mInflater;
    
    private ViewHolder buttomViewHolder;
    
    protected CallBack callBack;
    
    public CommonrRecyclerAdapter(Context context, List<T> datas)
    {
        mContext = context;
        mInflater = LayoutInflater.from(context);
        mDatas = datas;
    }
    
    public CommonrRecyclerAdapter(Context context, List<T> datas, CallBack callBack)
    {
        mContext = context;
        mInflater = LayoutInflater.from(context);
        mDatas = datas;
        this.callBack = callBack;
    }
    
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
    {
        convert(holder, mDatas.get(position));
    }
    
    @Override
    public int getItemCount()
    {
        return mDatas.size();
    }
    
    public abstract void convert(RecyclerView.ViewHolder holder, T t);
    
    /**
     * 底部view加载更多
     *
     * @param parent
     * @return
     */
    public RecyclerView.ViewHolder getButtomViewHolder(ViewGroup parent)
    {
        buttomViewHolder = ViewHolder.get(mContext, parent, R.layout.recycler_but_item_view, 0);
        return buttomViewHolder;
    }
    
}
